package com.spoplar.test;

import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;

public class TopicsProductor {

	private static final String USER = ActiveMQConnection.DEFAULT_USER;
	private static final String PASS = ActiveMQConnection.DEFAULT_PASSWORD;
	private static final String BROKER_URL = ActiveMQConnection.DEFAULT_BROKER_URL;
	
	
	public static void main(String[] args) throws JMSException {
		
		ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(USER, PASS, BROKER_URL);
		
		Connection connection = factory.createConnection();
		connection.start();
		
		Session session = connection.createSession(true,Session.AUTO_ACKNOWLEDGE);
		Destination destination = session.createTopic("new topics");
		MessageProducer producer = session.createProducer(destination);
		TextMessage txMessage = session.createTextMessage("topics ....");
		producer.send(txMessage);
		session.commit();
		
		
		producer.close();
		session.close();
		connection.close();
	}
}
